package com.hsgene.user.domain;

import com.hsgene.common.util.basic.SimpleRegexUtils;
import com.hsgene.common.util.exception.IllegalParamException;
import com.hsgene.common.util.validation.FieldChecker;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 运营人员账号信息表
 *
 * @author wangbing
 * @version 1.0, 2018/10/17
 */
public class GeneticTestingOperationAccount implements Serializable {

    private static final long serialVersionUID = -761413099362005020L;

    /**
     * 序号
     */
    private int number;

    /**
     * 用户主键id
     */
    private String id;

    /**
     * 运营人员登录后台系统的用户名
     */
    private String name;

    /**
     * 运营人员登录后台系统的密码
     */
    private String password;

    /**
     * 电话号码
     */
    private String phone;

    /**
     * 真实姓名
     */
    private String realName;

    /**
     * 创建时间
     */
    private Date createDateTime;

    /**
     * 更新时间
     */
    private Date updateDateTime;

    /**
     * 业务数据逻辑删除 0-代表未删除   1-代表删除
     */
    private Integer deleteFlag;

    /**
     * 职位ID
     */
    private String positionId;

    /**
     * 冗余职位名称
     */
    private String positionName;

    /**
     * 冗余部门ID
     */
    private String departmentId;

    /**
     * 冗余部门名称
     */
    private String departmentName;

    /**
     * 冗余公司ID
     */
    private String companyId;

    /**
     * 冗余公司名称
     */
    private String companyName;

    /**
     * 0-女  1-男
     */
    private Integer gender;

    /**
     * 最近一次登录时间
     */
    private Date latestLoginDateTime;

    /**
     * 是否系统超级管理员（false：不是；true：是）
     */
    private Boolean systemSuper;
    /**
     * 用户类型0-平台用户，1-机构用户
     */
    private Integer userType=0;

    public void check() {
        check(true);
    }

    public void check(boolean isSave) {
        FieldChecker.checkEmpty(phone, "电话号码");
        if (!SimpleRegexUtils.isMobile(phone)) {
            throw new IllegalParamException("电话号码格式错误");
        }
        this.name = StringUtils.isBlank(this.name) ? this.phone : this.name;
        if (isSave) {
            FieldChecker.checkMaxLength(realName, 255, "真实姓名");
        }
        FieldChecker.checkEmpty(gender, "性别");
        FieldChecker.checkEmpty(companyId, "公司ID");
        FieldChecker.checkEmpty(departmentId, "部门ID");
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
        this.number = number;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public Date getCreateDateTime() {
        return createDateTime;
    }

    public void setCreateDateTime(Date createDateTime) {
        this.createDateTime = createDateTime;
    }

    public Date getUpdateDateTime() {
        return updateDateTime;
    }

    public void setUpdateDateTime(Date updateDateTime) {
        this.updateDateTime = updateDateTime;
    }

    public Integer getDeleteFlag() {
        return deleteFlag;
    }

    public void setDeleteFlag(Integer deleteFlag) {
        this.deleteFlag = deleteFlag;
    }

    public String getPositionId() {
        return positionId;
    }

    public void setPositionId(String positionId) {
        this.positionId = positionId;
    }

    public String getPositionName() {
        return positionName;
    }

    public void setPositionName(String positionName) {
        this.positionName = positionName;
    }

    public String getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(String departmentId) {
        this.departmentId = departmentId;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public Integer getGender() {
        return gender;
    }

    public void setGender(Integer gender) {
        this.gender = gender;
    }

    public Date getLatestLoginDateTime() {
        return latestLoginDateTime;
    }

    public void setLatestLoginDateTime(Date latestLoginDateTime) {
        this.latestLoginDateTime = latestLoginDateTime;
    }

    public Boolean getSystemSuper() {
        return systemSuper;
    }

    public void setSystemSuper(Boolean systemSuper) {
        this.systemSuper = systemSuper;
    }

    public Integer getUserType() {
        return userType;
    }

    public void setUserType(Integer userType) {
        this.userType = userType;
    }
}
